import crypt5

def read_file(file):
	wordlist2 = []
	with open(file,"r") as f :
		wordlist = f.readlines()

	for i in wordlist:
		wordlist2.append(i.strip())

	return wordlist2

def yx_user(userlist):
	yx_userlist = []
	for i in userlist:
		if(len(i.split(":")[1]) > 3):
			yx_userlist.append(i)
	return yx_userlist

def boom_saltpass(wordlist,yx_userlist):
	print("正在爆破中：")
	for user in yx_userlist:
		username = user.split(":")[0]
		hashpass = user.split(":")[1]
		salt = hashpass.rpartition("$")[0]
		print(f"正在爆破用户{username}.....")
		for word in wordlist:
			if crypt5.crypt_pass().passlibCrypt(word,salt) == hashpass:
				print(f"成功爆破密码！用户名为{username} ,密码为：{word}")
				break


if __name__ == '__main__':
	wordlist = read_file("pass.txt")
	userlist = read_file("shadow.txt")
	yx_userlist = yx_user(userlist)
	boom_saltpass(wordlist,yx_userlist)